﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;

using System.Diagnostics;
using PRET.PRETService.Data;

namespace PRET.TestService1
{
    public partial class Form1 : Form
    {

        private readonly static string LogSource = "PRETLogSource";
        private readonly static string LogName = "PRETLog";

        private void InitializeEventLog()
        {
            if (!EventLog.SourceExists(LogSource))
                EventLog.CreateEventSource(LogSource, LogName);
            log.Source = LogSource;
            log.Log = LogName;
        }

        public Form1()
        {
            InitializeComponent();
            InitializeEventLog();
            using(ServiceAdapter adapter = new ServiceAdapter(log))
            {
                //adapter.CollectionProlineStandby();
                //adapter.CollectionProlineEff();
                adapter.CreateAllTablesInDB();
                adapter.CollectionProduceTask();
                

                adapter.CollectionHighLowVoltage();
                //log.WriteEntry("开始从WINCC中收集挤出机数据");
                adapter.CollectionJCJData();
                //adapter.CollectionJCJData2();
                //log.WriteEntry("完成：从WINCC中收集挤出机数据");

                //log.WriteEntry("开始从WINCC中收集均化机数据");
                adapter.CollectionJHJData();
                //log.WriteEntry("完成：从WINCC中收集均化机数据");

                //log.WriteEntry("开始从WINCC中收集待产信息数据");
                adapter.CollectionWaitingOrder();
                //log.WriteEntry("完成：从WINCC中收集待产信息数据");

                //log.WriteEntry("开始从WINCC中收集班组工作时间数据");
                adapter.CollectionTeamWorkTime();
                //log.WriteEntry("完成：从WINCC中收集班组工作时间数据");

                //log.WriteEntry("开始从WINCC中收集高低柜数据");
                adapter.CollectionHighLowData();
                //log.WriteEntry("完成：从WINCC中收集高低柜数据");

                //log.WriteEntry("开始从WINCC中收集温湿度数据");
                adapter.CollectionHumTemData();
                //log.WriteEntry("完成：从WINCC中收集温湿度数据");

                //log.WriteEntry("开始更新滑石母粒机信息到ERP表格中");
                adapter.CollectionHSMLJData();
                //log.WriteEntry("完成：更新滑石母粒机信息到ERP表格中");

                //log.WriteEntry("开始更新订单生产信息到ERP表格中");
                adapter.UpdateOrderFeedback();
                //log.WriteEntry("完成：更新订单生产信息到ERP表格中");
            }
        }
    }
}
